package org.seven.jrdp.web.t;

import java.util.List;

import org.seven.jrdp.biz.t.model.TCk;
import org.seven.jrdp.biz.t.model.TKq;
import org.seven.jrdp.biz.t.service.TCkService;
import org.seven.jrdp.commons.model.Option;
import org.seven.jrdp.commons.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/mgt/t/ck")
public class TCkController {
	@Autowired
	private TCkService tCkService;

	@GetMapping("/{view}")
	public ModelAndView view(@PathVariable String view) {
		return new ModelAndView("mgt/t/ck/ck_" + view);
	}

	@PostMapping("/find")
	public List<TCk> find() {
		List<TCk> list = tCkService.find();
		return list;
	}

	@PostMapping("/insert")
	public Result insert(TCk tCk) {
		tCkService.insert(tCk);
		return Result.SUCCESS;
	}

	@PostMapping("/delete")
	public Result delete(String id) {
		tCkService.delete(id);
		return Result.SUCCESS;
	}

	@PostMapping("/kq")
	public List<TKq> kq(String ckmc) {
		List<TKq> list = tCkService.findKq(ckmc);
		return list;
	}

	@RequestMapping("/option")
	public List<Option> option() {
		return tCkService.getOption();
	}
}